Skip to content

Add quant mode for qwen3.5 - #2096

Closed
Akshay Sonawane (apsonawane) wants to merge 5 commits into
mainfrom
asonawane/qwen35
Closed

Add quant mode for qwen3.5#2096
Akshay Sonawane (apsonawane) wants to merge 5 commits into
mainfrom
asonawane/qwen35

Conversation

@apsonawane

Copy link
Copy Markdown
Contributor

This pull request introduces a new quant_mode option for configuring quantization behavior in Qwen model builders, allowing users to balance inference speed and model accuracy. The changes validate the quant_mode parameter, document its usage, and implement three quantization strategies: "default", "hybrid", and "int4".

Key changes:

Quantization Mode Validation and Configuration

  • Added validation for the quant_mode option in the check_extra_options function to ensure only supported values ("default", "hybrid", "int4") are accepted.
  • In the Qwen model builder, now reads quant_mode from extra_options or the QWEN35_QUANT_MODE environment variable, defaulting to "default" if unset.

Quantization Strategy Implementation

  • Implemented three quantization strategies:
    • "default": INT8 quantization for all linear attention and MLP layers (most accurate).
    • "hybrid": INT8 for linear attention projections, INT4 for MLPs (balanced speed and accuracy).
    • "int4": INT4 for all layers (fastest, may degrade quality).

Documentation

  • Added inline documentation describing the quantization modes and their effects on model performance and quality.

Copilot AI review requested due to automatic review settings April 22, 2026 16:00
@apsonawane
Akshay Sonawane (apsonawane) marked this pull request as draft April 22, 2026 16:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new quant_mode option to the Qwen3.5 model builder to control mixed-precision quantization behavior (default/hybrid/int4), with corresponding validation in the shared extra-options parsing.

Changes:

  • Added quant_mode validation in check_extra_options (builder.py).
  • Implemented quantization strategy selection in the Qwen3.5 builder based on extra_options["quant_mode"] or QWEN35_QUANT_MODE (qwen.py).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
src/python/py/models/builders/qwen.py Reads quant_mode and applies INT8 overrides for selected node subsets under different modes.
src/python/py/models/builder.py Validates quant_mode values provided via --extra_options.

Comment thread src/python/py/models/builders/qwen.py Outdated
Comment thread src/python/py/models/builders/qwen.py Outdated
Comment thread src/python/py/models/builder.py Outdated
Comment thread src/python/py/models/builder.py Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

Comment thread src/python/py/models/builder.py
Comment thread src/python/py/models/builders/qwen.py
Comment thread src/python/py/models/builder.py
@xadupre

Copy link
Copy Markdown
Member

#2078 is adding many unittest on modelbuilder, that would be great if you add for your changes once this PR is merged.

1 similar comment
@xadupre

Copy link
Copy Markdown
Member

#2078 is adding many unittest on modelbuilder, that would be great if you add for your changes once this PR is merged.

@apsonawane
Akshay Sonawane (apsonawane) marked this pull request as ready for review April 23, 2026 20:49
@apsonawane

Copy link
Copy Markdown
Contributor Author

Created a new PR to use existing int4_algo_config instead of creating a new one: #2100

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants